<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Box2D: b2PolygonShape Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="icon.gif"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Box2D
   &#160;<span id="projectnumber">2.2.1</span>
   </div>
   <div id="projectbrief">A 2D Physics Engine for Games</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-attribs">Public Attributes</a>  </div>
  <div class="headertitle">
<div class="title">b2PolygonShape Class Reference</div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="b2PolygonShape" --><!-- doxytag: inherits="b2Shape" -->
<p><code>#include &lt;<a class="el" href="b2_polygon_shape_8h_source.html">b2PolygonShape.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for b2PolygonShape:</div>
<div class="dyncontent">
 <div class="center">
  <img src="classb2_polygon_shape.png" usemap="#b2PolygonShape_map" alt=""/>
  <map id="b2PolygonShape_map" name="b2PolygonShape_map">
<area href="classb2_shape.html" alt="b2Shape" shape="rect" coords="0,0,108,24"/>
</map>
 </div></div>

<p><a href="classb2_polygon_shape-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a38cf6a915a85691746465c9dbfc5aeb6"></a><!-- doxytag: member="b2PolygonShape::Clone" ref="a38cf6a915a85691746465c9dbfc5aeb6" args="(b2BlockAllocator *allocator) const " -->
<a class="el" href="classb2_shape.html">b2Shape</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_polygon_shape.html#a38cf6a915a85691746465c9dbfc5aeb6">Clone</a> (<a class="el" href="classb2_block_allocator.html">b2BlockAllocator</a> *allocator) const </td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Implement <a class="el" href="classb2_shape.html">b2Shape</a>. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int32&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_polygon_shape.html#ae844375297d19744e01a37b397a5baba">GetChildCount</a> () const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_polygon_shape.html#a8aa13a7584b58f08be4d84181b5a86a8">Set</a> (const <a class="el" href="structb2_vec2.html">b2Vec2</a> *vertices, int32 vertexCount)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_polygon_shape.html#a6bb90df8b4a40d1c53b64cc352a855dd">SetAsBox</a> (float32 hx, float32 hy)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_polygon_shape.html#a890690250115483da6c7d69829be087e">SetAsBox</a> (float32 hx, float32 hy, const <a class="el" href="structb2_vec2.html">b2Vec2</a> &amp;center, float32 angle)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_polygon_shape.html#a69ccc2f671394b3cc1a00a16ef36b12b">TestPoint</a> (const <a class="el" href="structb2_transform.html">b2Transform</a> &amp;transform, const <a class="el" href="structb2_vec2.html">b2Vec2</a> &amp;p) const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac13bded10d09c341f64aaa2750dda6b5"></a><!-- doxytag: member="b2PolygonShape::RayCast" ref="ac13bded10d09c341f64aaa2750dda6b5" args="(b2RayCastOutput *output, const b2RayCastInput &amp;input, const b2Transform &amp;transform, int32 childIndex) const " -->
bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_polygon_shape.html#ac13bded10d09c341f64aaa2750dda6b5">RayCast</a> (<a class="el" href="structb2_ray_cast_output.html">b2RayCastOutput</a> *output, const <a class="el" href="structb2_ray_cast_input.html">b2RayCastInput</a> &amp;input, const <a class="el" href="structb2_transform.html">b2Transform</a> &amp;transform, int32 childIndex) const </td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Implement <a class="el" href="classb2_shape.html">b2Shape</a>. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_polygon_shape.html#a00e225b0321bf6bb231a554036ffdf23">ComputeAABB</a> (<a class="el" href="structb2_a_a_b_b.html">b2AABB</a> *aabb, const <a class="el" href="structb2_transform.html">b2Transform</a> &amp;transform, int32 childIndex) const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_polygon_shape.html#ad86c4c2a83a7122599462da83bf35389">ComputeMass</a> (<a class="el" href="structb2_mass_data.html">b2MassData</a> *massData, float32 density) const </td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae220f24c42eff4aef4cd452676ca2ced"></a><!-- doxytag: member="b2PolygonShape::GetVertexCount" ref="ae220f24c42eff4aef4cd452676ca2ced" args="() const " -->
int32&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_polygon_shape.html#ae220f24c42eff4aef4cd452676ca2ced">GetVertexCount</a> () const </td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the vertex count. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a88cdb687ec7dc0cbcf4bd25fd37f4da1"></a><!-- doxytag: member="b2PolygonShape::GetVertex" ref="a88cdb687ec7dc0cbcf4bd25fd37f4da1" args="(int32 index) const " -->
const <a class="el" href="structb2_vec2.html">b2Vec2</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classb2_polygon_shape.html#a88cdb687ec7dc0cbcf4bd25fd37f4da1">GetVertex</a> (int32 index) const </td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Get a vertex by index. <br/></td></tr>
<tr><td colspan="2"><h2><a name="pub-attribs"></a>
Public Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae8f5bd2f13f1e9b741c33350ba19cd9f"></a><!-- doxytag: member="b2PolygonShape::m_centroid" ref="ae8f5bd2f13f1e9b741c33350ba19cd9f" args="" -->
<a class="el" href="structb2_vec2.html">b2Vec2</a>&#160;</td><td class="memItemRight" valign="bottom"><b>m_centroid</b></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a11ee5c107660be5da25f0e164aaccd53"></a><!-- doxytag: member="b2PolygonShape::m_vertices" ref="a11ee5c107660be5da25f0e164aaccd53" args="[b2_maxPolygonVertices]" -->
<a class="el" href="structb2_vec2.html">b2Vec2</a>&#160;</td><td class="memItemRight" valign="bottom"><b>m_vertices</b> [b2_maxPolygonVertices]</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a97cdcec277321c62ecdf93cb649958ce"></a><!-- doxytag: member="b2PolygonShape::m_normals" ref="a97cdcec277321c62ecdf93cb649958ce" args="[b2_maxPolygonVertices]" -->
<a class="el" href="structb2_vec2.html">b2Vec2</a>&#160;</td><td class="memItemRight" valign="bottom"><b>m_normals</b> [b2_maxPolygonVertices]</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a45902db31f1a135b259f7967fd05f2f0"></a><!-- doxytag: member="b2PolygonShape::m_vertexCount" ref="a45902db31f1a135b259f7967fd05f2f0" args="" -->
int32&#160;</td><td class="memItemRight" valign="bottom"><b>m_vertexCount</b></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>A convex polygon. It is assumed that the interior of the polygon is to the left of each edge. Polygons have a maximum number of vertices equal to b2_maxPolygonVertices. In most cases you should not need many vertices for a convex polygon. </p>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a00e225b0321bf6bb231a554036ffdf23"></a><!-- doxytag: member="b2PolygonShape::ComputeAABB" ref="a00e225b0321bf6bb231a554036ffdf23" args="(b2AABB *aabb, const b2Transform &amp;transform, int32 childIndex) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void b2PolygonShape::ComputeAABB </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structb2_a_a_b_b.html">b2AABB</a> *&#160;</td>
          <td class="paramname"><em>aabb</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="structb2_transform.html">b2Transform</a> &amp;&#160;</td>
          <td class="paramname"><em>transform</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int32&#160;</td>
          <td class="paramname"><em>childIndex</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td> const<code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classb2_shape.html#a88e9807fab0c8ca9a98d8926e50a1411">b2Shape::ComputeAABB</a> </dd></dl>

<p>Implements <a class="el" href="classb2_shape.html#a88e9807fab0c8ca9a98d8926e50a1411">b2Shape</a>.</p>

</div>
</div>
<a class="anchor" id="ad86c4c2a83a7122599462da83bf35389"></a><!-- doxytag: member="b2PolygonShape::ComputeMass" ref="ad86c4c2a83a7122599462da83bf35389" args="(b2MassData *massData, float32 density) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void b2PolygonShape::ComputeMass </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structb2_mass_data.html">b2MassData</a> *&#160;</td>
          <td class="paramname"><em>massData</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float32&#160;</td>
          <td class="paramname"><em>density</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td> const<code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classb2_shape.html#a61b365526241b47f124789b0309cac69">b2Shape::ComputeMass</a> </dd></dl>

<p>Implements <a class="el" href="classb2_shape.html#a61b365526241b47f124789b0309cac69">b2Shape</a>.</p>

</div>
</div>
<a class="anchor" id="ae844375297d19744e01a37b397a5baba"></a><!-- doxytag: member="b2PolygonShape::GetChildCount" ref="ae844375297d19744e01a37b397a5baba" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32 b2PolygonShape::GetChildCount </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const<code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classb2_shape.html#a05a3c445017d96df9238ceefe6ce37ab" title="Get the number of child primitives.">b2Shape::GetChildCount</a> </dd></dl>

<p>Implements <a class="el" href="classb2_shape.html#a05a3c445017d96df9238ceefe6ce37ab">b2Shape</a>.</p>

</div>
</div>
<a class="anchor" id="a8aa13a7584b58f08be4d84181b5a86a8"></a><!-- doxytag: member="b2PolygonShape::Set" ref="a8aa13a7584b58f08be4d84181b5a86a8" args="(const b2Vec2 *vertices, int32 vertexCount)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void b2PolygonShape::Set </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="structb2_vec2.html">b2Vec2</a> *&#160;</td>
          <td class="paramname"><em>vertices</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int32&#160;</td>
          <td class="paramname"><em>vertexCount</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Copy vertices. This assumes the vertices define a convex polygon. It is assumed that the exterior is the the right of each edge. The count must be in the range [3, b2_maxPolygonVertices]. </p>

</div>
</div>
<a class="anchor" id="a6bb90df8b4a40d1c53b64cc352a855dd"></a><!-- doxytag: member="b2PolygonShape::SetAsBox" ref="a6bb90df8b4a40d1c53b64cc352a855dd" args="(float32 hx, float32 hy)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void b2PolygonShape::SetAsBox </td>
          <td>(</td>
          <td class="paramtype">float32&#160;</td>
          <td class="paramname"><em>hx</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float32&#160;</td>
          <td class="paramname"><em>hy</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Build vertices to represent an axis-aligned box. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">hx</td><td>the half-width. </td></tr>
    <tr><td class="paramname">hy</td><td>the half-height. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a890690250115483da6c7d69829be087e"></a><!-- doxytag: member="b2PolygonShape::SetAsBox" ref="a890690250115483da6c7d69829be087e" args="(float32 hx, float32 hy, const b2Vec2 &amp;center, float32 angle)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void b2PolygonShape::SetAsBox </td>
          <td>(</td>
          <td class="paramtype">float32&#160;</td>
          <td class="paramname"><em>hx</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float32&#160;</td>
          <td class="paramname"><em>hy</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="structb2_vec2.html">b2Vec2</a> &amp;&#160;</td>
          <td class="paramname"><em>center</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float32&#160;</td>
          <td class="paramname"><em>angle</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Build vertices to represent an oriented box. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">hx</td><td>the half-width. </td></tr>
    <tr><td class="paramname">hy</td><td>the half-height. </td></tr>
    <tr><td class="paramname">center</td><td>the center of the box in local coordinates. </td></tr>
    <tr><td class="paramname">angle</td><td>the rotation of the box in local coordinates. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a69ccc2f671394b3cc1a00a16ef36b12b"></a><!-- doxytag: member="b2PolygonShape::TestPoint" ref="a69ccc2f671394b3cc1a00a16ef36b12b" args="(const b2Transform &amp;transform, const b2Vec2 &amp;p) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool b2PolygonShape::TestPoint </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="structb2_transform.html">b2Transform</a> &amp;&#160;</td>
          <td class="paramname"><em>transform</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="structb2_vec2.html">b2Vec2</a> &amp;&#160;</td>
          <td class="paramname"><em>p</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td> const<code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classb2_shape.html#a6ac968e403e2d93e8ae46d728a2e50fa">b2Shape::TestPoint</a> </dd></dl>

<p>Implements <a class="el" href="classb2_shape.html#a6ac968e403e2d93e8ae46d728a2e50fa">b2Shape</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="b2_polygon_shape_8h_source.html">b2PolygonShape.h</a></li>
<li>b2PolygonShape.cpp</li>
</ul>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Sat Sep 17 2011 17:35:56 for Box2D by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
